import pageination from '../../components/pageination/pageination.vue'
export default {
	//数据
	data() {
		return {
			modelShow: false,
      total: 0, //总条数
      page: 1, //当前页
      size: 10,//每页显示条数
      portalMainImgUrl: "", //门户主图
      portalSecondImgUrl: "", //门户次图
      downloadRelease: {},
      downloadReleaseList: [], //政策集合信息
      fatherIndex:0, //一级菜单下标
		}
	},
  components: {
    pageination
  },
	created() { //调用方法
    //初始化下载发布分页信息
    this.searchTodo();

    let that = this;
    //初始化门户图片信息
    that.$post(
      that.urls.getAllPortalConfigList, {
        "type": 0
      }
    )
    .then(function(res) {
      if(res.success) {
        let portalConfigList = res.data;
        for(let i = 0, len = portalConfigList.length; i < len; i++) {
          if(portalConfigList[i].baseType == 0) {
            that.portalMainImgUrl = portalConfigList[i].url; //门户主图
          } else if(portalConfigList[i].baseType == 1) {
            that.portalSecondImgUrl = portalConfigList[i].url; //门户次图
          }
        }
      }
    })
	},
	updated:function(){
		if(this.getParamValue("fatherIndex")){
			this.fatherIndex=this.getParamValue("fatherIndex");
		}
	},
	mounted() {

	},
	methods: { //写函数方法
//页码切换执行方法
    pageFn: function(val, pid) {
      this.page = parseInt(val);
      //此处调列表数据接口
      this.searchTodo(pid); //查询新闻
    },
    /**返回子组件用户选择的一页显示条数**/
    obtainChild: function(data) {
      this.row = data;
    },
    //搜索数据列表
    searchTodo: function() {
      let that = this;
      that.$post(
        that.urls.getDownloadReleasePageInfo,
        {"pageNum": that.page,"pageSize": that.size}
      )
      .then(function(res) {
        if(res.success) {
          that.downloadReleaseList = res.pageInfo.list;
          that.total = res.pageInfo.total;
          that.page = res.pageInfo.pageNum;
        }
      })
    },
    //获取下载信息
    getDownloadRelease: function(id) {
      let that = this;
      that.downloadRelease = {};
      if (id != null) {
        that.$post(
          that.urls.getDownloadRelease,
          {"id": id}
        )
        .then(function(res) {
          if(res.success) {
            that.downloadRelease = res.data;
          }
        })
      }
    },
    openModal: function(id) {
			this.modelShow = true;
			this.getDownloadRelease(id);
		},
    //下载数据
    downloadData: function(url) {
      if (url != null && url != "") {
        window.location.href = this.urls.download + "?path=" + url;
      }
    },
		closeModel: function() {
			this.modelShow = false;
		},
	}
}
